Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test the Dockerfile #3677

Merged
merged 6 commits into from
Dec 24, 2019
Merged

Test the Dockerfile #3677

merged 6 commits into from
Dec 24, 2019

Conversation

pierreprinetti
Copy link
Contributor

@pierreprinetti pierreprinetti commented Dec 1, 2019

Add a Test Dockerfile job to Travis.

The new job:

  • checks that docker build succeeds
  • performs a few very basic calls against the app in the container

@pierreprinetti pierreprinetti force-pushed the test_docker branch 6 times, most recently from 350b616 to 8c36d4e Compare December 2, 2019 08:39
@pierreprinetti pierreprinetti marked this pull request as ready for review December 2, 2019 08:39
@pierreprinetti pierreprinetti changed the title WIP: Test the Dockerfile Test the Dockerfile Dec 2, 2019
Note by muxator:
This commit introduced a copied & modified version of the testing files
loadSettings.js and pad.js.

It's Christmas night, and we want to shipt this feature, so I merged it anyway,
adding a note in both the original and copied files so that hopefully someone
in the distant future is going to merge them back again.
@pierreprinetti pierreprinetti force-pushed the test_docker branch 5 times, most recently from c9506c4 to 456bb4a Compare December 3, 2019 23:04
@muxator
Copy link
Contributor

muxator commented Dec 19, 2019

I've missed this. Is this PR still valid?

@pierreprinetti
Copy link
Contributor Author

Absolutely. I have rebased and it still succeeds.

I am thinking of re-enabling backend testing in the CI in a folllow-up.

@pierreprinetti
Copy link
Contributor Author

pierreprinetti commented Dec 19, 2019

Note that frontend tests are still disabled in PRs, and they will continue to run on master. In that regard, this PR does not change anything.

Note that due to security restrictions, the Sauce Labs addon is not available on pull request

@pierreprinetti
Copy link
Contributor Author

I feel the urge to clarify:

  • backend tests are currently NOT run in Travis, this PR does not change anything in that regard
  • frontend tests are currently NOT run in PRs, this PR does not change anything in that regard
  • the container was never tested, this PR introduces a smoke test.

The dependency on java was introduced in 2012 (c021cf5) to start
Sauce-Connect from sauce labs.

Probably at the time it was a runtime dependency, but it is no longer the case
today. It is possible that java was already not needed when db003a1 changed
from downloading Sauce-Connect-latest.zip to sc-latest-linux.tar.gz.

Moreover, I am quite sure tests/frontend/travis/sauce_tunnel.sh no longer works
today, because tests/frontend/travis/sauce_tunnel.sh downloads from an url that
gives HTTP/404 now: sc-latest-linux.tar.gz if no longer a valid file name, we
would need to explicitly download a specific version.
@muxator muxator force-pushed the test_docker branch 2 times, most recently from 2263e07 to 16ffc45 Compare December 21, 2019 08:26
@muxator
Copy link
Contributor

muxator commented Dec 21, 2019

I am having a look at this now, having a look at TravisCI doc in the meantime :)

If I get it right, the old travis.yml consisted of a single job in the "global scope", run in a VM with nodejs installed, and run tests/frontend/travis/runner.sh.

9ef3342 creates a jobs section for running multiple jobs, and moves the old install and script sections under that, then adds another job that performs the docker build (and succeeds if its exit code is 0).

If I understood this correctly, I am going to proceed to split these two passes.

BTW, in the process I have seen that the jdk dependency was no longer needed (see 86f64a9), and I am now wondering how the frontend test can work at all, given that there is a command that is guaranteed to fail (tests/frontend/travis/sauce_tunnel.sh)

Edit: apparently the failing script was disabled in 2017, and this explains my doubts about tests/frontend/travis/sauce_tunnel.sh. See #2948 (comment). The java dependency can be safely killed.

@muxator
Copy link
Contributor

muxator commented Dec 21, 2019

Note to self: the relevant TravisCI docs for moving under a jobs section is https://docs.travis-ci.com/user/build-matrix/

There are two ways to specify multiple parallel jobs (what we call the build matrix) with a single .travis.yml configuration file:

  • combine a language-and-environment dependent set of configuration options to automatically create a matrix of all possible combinations. This is called matrix expansion. For example, the following configuration produces a build matrix that expands to 8 individual (2 * 2 * 2) jobs.
  • specify the exact combination of configurations you want in jobs.include. For example, if not all of those combinations are interesting, you can specify just the combinations you want

muxator and others added 2 commits December 21, 2019 10:10
… later

In the next commit Pierre will start adding tests for the docker build, and this
lays out the structure for doing that.
No functional changes.

The relevant TravisCI docs that motivates moving under a jobs section is
https://docs.travis-ci.com/user/build-matrix/

> There are two ways to specify multiple parallel jobs (what we call the build
> matrix) with a single .travis.yml configuration file:
>
> * combine a language-and-environment dependent set of configuration options to
>   automatically create a matrix of all possible combinations. This is called
>   matrix expansion. For example, the following configuration produces a build
>   matrix that expands to 8 individual (2 * 2 * 2) jobs
>   [...]
>
> * specify the exact combination of configurations you want in jobs.include.
>   For example, if not all of those combinations are interesting, you can
>   specify just the combinations you want
Add a `Test Dockerfile` job to Travis that checks the `docker build` exit
code.
More useful tests can be added later.
@pierreprinetti
Copy link
Contributor Author

LGTM

In the following commits Pierre is going to copy & modify some files.
This commit prepares the source files in order to minimize those differences,
so we can re-unify them as soon as possible.

No functional changes.
This is just needed to slim up the diffs for the next commits.
Non functional changes.
@muxator
Copy link
Contributor

muxator commented Dec 24, 2019

The last commit in this series ("ci: test basic application response of the docker build", 13d9e86) copies & modifies two settings files.

It's Christmas night and this feature merits to be shipped, so let's go with it. As minimum measure, I have rewritten the commit history to make explicit which files were copied and minimize the differences.
The resulting diffs are interesting, and I would like some comments about them, particularly about the second one:

$ diff --unified backend/loadSettings.js container/loadSettings.js (this is easy)
--- backend/loadSettings.js     2019-12-25 00:09:53.368516235 +0100
+++ container/loadSettings.js   2019-12-25 00:09:53.372516247 +0100
@@ -9,13 +9,17 @@
 const fs = require('fs');
 
 function loadSettings(){
-  var settingsStr = fs.readFileSync(__dirname+"/../../settings.json").toString();
+  var settingsStr = fs.readFileSync(__dirname+"/../../settings.json.docker").toString();
   // try to parse the settings
   try {
     if(settingsStr) {
       settingsStr = jsonminify(settingsStr).replace(",]","]").replace(",}","}");
       var settings = JSON.parse(settingsStr);
 
+      // custom settings for running in a container
+      settings.ip = 'localhost';
+      settings.port = '9001';
+
       return settings;
     }
   }catch(e){
diff --unified backend/specs/api/pad.js container/specs/api/pad.js
--- backend/specs/api/pad.js	2019-12-25 00:09:53.368516235 +0100
+++ container/specs/api/pad.js	2019-12-25 00:09:53.372516247 +0100
@@ -47,7 +23,6 @@
   it('finds the version tag', function(done) {
     api.get('/api/')
     .expect(function(res){
-      apiVersion = res.body.currentVersion;
       if (!res.body.currentVersion) throw new Error("No version set in API");
       return;
     })
@@ -57,592 +32,7 @@
 
 describe('Permission', function(){
   it('errors with invalid APIKey', function(done) {
-    // This is broken because Etherpad doesn't handle HTTP codes properly see #2343
-    // If your APIKey is password you deserve to fail all tests anyway
-    var permErrorURL = '/api/'+apiVersion+'/createPad?apikey=password&padID=test';
-    api.get(permErrorURL)
+    api.get('/api/'+apiVersion+'/createPad?apikey=wrong_password&padID=test')
     .expect(401, done)
   });
 })

I will open an issue in Etherpad to remember to get rid of this duplication asap.

Edit: opened #3686, let's continue there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants